// components/foot/index.js

const app = getApp()
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    sponsorlogoes: {
      type: [],
      value: [],
      observer: function (newVal, oldVal) {
      
        this._sponsorlogoespropertyChange(newVal,oldVal);
   
     } // 属性被改变时执行的函数（可选），也可以写成在methods段中定义的方法名字符串, 如：'_propertyChange'
    
    },
    baseimgaeUrl: {
      type: String,
      value: ""
    }
  },

  /**
   * 组件的初始数据
   */
  data: {  
    staticUrl: app.globalData.staticUrl,
    innersponsorlogoes:[],
  },

  /**
   * 组件的方法列表
   */
  methods: {
    _sponsorlogoespropertyChange:function(newVal,oldVal){

      var loges = newVal;
      console.log("loges",loges);
      if(newVal && !loges.footurl ){
      loges.forEach(item=>{
        item.sponsoresname = item.sponsoresname.replace(' ','&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
        item.logoes.forEach(sitem=>{ 
          var wxminiapp =  sitem.imagetitle?sitem.imagetitle.split('-'):'';
          if(wxminiapp.length>1){
            sitem.wxappid = wxminiapp[1];
          }})
       
      })
    
    }
    loges.ads = app.globalData.bannerAd; 

    this.setData({
      innersponsorlogoes: loges,
      
    });

    console.log("innersponsorlogoes",this.data.innersponsorlogoes);

  },
  opensponsr:function(e){
    var loges = e.currentTarget.dataset.item;
    if(loges.wxappid){
      wx.navigateToMiniProgram({
        'appId':loges.wxappid,
      })
    }
  },
  openmp:function(e){
     var url = this.data.staticUrl + '/images/official-accountqrcode.jpg';
      wx.previewImage({
        urls: [url],
      })
  },

  openmedia:function(){
    //console.log('openmedia',e);
      if(this.data.innersponsorlogoes.ads.mediasrc){
      
            this.setData({isplay:!this.data.isplay})
            if(this.data.isplay){
              var videoplay = wx.createVideoContext('video', this);
              console.log('openmedia',videoplay);
              videoplay.play();
            }
      }
  },
  }
})